<%@page import="java.util.UUID"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<%
    String uuid = UUID.randomUUID().toString();
    request.setAttribute("uuid", uuid);
%>
<style type="text/css">
	.addOrderBtnCss{
		color: red;font-size: 14px;font-weight: bold;cursor: pointer; padding: 2px;
	}
	.riskWO{
		display: none;
	}
	.queryInputLabel{
		color: orange;
	}
	.autoInputLabel{
		color: #3399FF;
	}
	.hide{
		display: none;
	}
</style>
<div class="container-fluid am-margin-top">
    	<form id="workOrderByUserForm">
	        <input type="hidden" name="zgdid"/>
	        <!-- 客户信息部分 -->
	        <ul class="nav nav-tabs" role="tablist">
				<li role="presentation" class="active">
					<a href="#${uuid}_clientDataTab" role="tab" data-toggle="tab">
						客户信息
					</a>
				</li>
			</ul>
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane fade in  active am-margin-top-sm" id="${uuid}_clientDataTab">
			        <div class="row">
						<div class="col-md-3">
							<div class="form-group"><label>来电号码</label>
								<input type="text" name="ldhm" class="form-control" check-type="required" readonly="readonly">
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>创建时间</label>
								<div>2016-09-09 12:12:12</div>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>通话时长</label>
								<div>53秒</div>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>业务来源</label>
				                <pf:dataDic var="item" dicCode="YWLY">
				                </pf:dataDic>
				                <div>电话呼入</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-3">
							<div class="form-group"><label>客户姓名</label>
								<input type="text" name="khxm" class="form-control" check-type="required" readonly="readonly">
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>客户类型</label>
								<select class="form-control"  name="khlx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="KHLX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>客户语言</label>
								<select class="form-control"  name="khyy" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="KHYY">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group" style="padding-top: 25px;">
								<!-- 
								<a href="javascript:void(0)" id="searchOrderBt" class="btn btn-warning">保存更新</a>
								 -->
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 客户信息部分结束 -->
		</form>
		<ul class="nav nav-tabs" role="tablist" id="orderNav">
			<li role="presentation" class="active">
				<a href="#${uuid}_fieldDataTab" role="tab" data-toggle="tab">
					工单信息
				</a>
			</li>
		</ul>
		<div class="tab-content" id="orderTab">
				<div role="tabpanel" class="tab-pane fade in  active am-margin-top-sx" id="${uuid}_fieldDataTab">
		   	  	  <form id="workOrderForm">
		   	  	  	<input type="hidden" name="id"/>
		   	  	  	<input type="hidden" name="clid"/>
		   	  	  	<input type="hidden" name="gdlcid"/>
		   	  	  	<input type="hidden" name="clzt"/>
		   	  	  	<input type="hidden" name="zhpdsj"/>
		   	  	   　 <!-- 公共上部分 -->
					<div class="row">
						<div class="col-md-3">
							<div class="form-group"><label>业务类型</label>
								<select class="form-control"  name="ywlx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="YWLX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>子业务类型</label>
								<select class="form-control"  name="zywlx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="ZYWLX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>疑难投诉</label>
								<select class="form-control"  name="ynts" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="YNTS">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<!-- 客服工单部分 -->
						<div class="col-md-3 serviceWO">
							<div class="form-group"><label>客户诉求</label>
								<select class="form-control"  name="khsq" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="KHSQ">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<!-- 客服工单部分结束 -->
					</div>
					<!-- 公共上部分结束 -->
					
					<!-- 风控工单部分 -->
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">交易手机号是否银行预留手机号</label>
								<select class="form-control"  name="jysjhsfyhylsjh" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>交易手机号是否属于本人</label>
								<select class="form-control"  name="jysjhmsfbr" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>呼叫转移</label>
								<select class="form-control"  name="hjzy" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>短信拦截</label>
								<select class="form-control"  name="dxlj" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label>接收呼转号码</label>
								<input type="text" class="form-control"  name="jszyhm" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">受益人</label>
								<input type="text" class="form-control"  name="syr" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>是否认识受益人</label>
								<select class="form-control"  name="sfrssydx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>是否认识交易手机</label>
								<select class="form-control"  name="sfrsjysj" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">呼转号码归属地</label>
								<input type="text" class="form-control"  name="hzhmgsd" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">呼转号码运营商</label>
								<input type="text" class="form-control"  name="hzhmyys" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">受益人手机号</label>
								<input type="text" class="form-control"  name="syrsjh" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">受益人手机号归属地</label>
								<input type="text" class="form-control"  name="syrsjhgsd" readonly="readonly"/>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label>与受益人关系</label>
								<select class="form-control"  name="ysydxgx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="QSGX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>手机品牌</label>
								<select class="form-control"  name="sjpp" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SJPP">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>手机系统</label>
								<select class="form-control"  name="sjxt" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SJXT">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>银行卡信息泄露</label>
								<select class="form-control"  name="yhkxxxl" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label>ID是否被盗</label>
								<select class="form-control"  name="idsfxl" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>ID注册邮箱</label>
								<select class="form-control"  name="idzcyx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>是否报警</label>
								<select class="form-control"  name="sfbj" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>手机系统是否越狱</label>
								<select class="form-control"  name="sjsfyy" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-12">
							<div class="form-group"><label>银行账号绑定业务情况</label>
								<pf:dataDic var="item" dicCode="BDYW">
					                    &nbsp;&nbsp;${item.name}&nbsp;<input type="checkbox" name="yhkbdyw" value="${item.value}" disabled="disabled">
					            </pf:dataDic>
					            <input type="text" class="form-control"  name="bdywbc" readonly="readonly" placeholder="其他说明"/>
							</div>
						</div>
					</div>
					<!-- 风控工单部分结束 -->
					
					<!-- 公共下部分 -->
					<div class="row">
						<div class="col-md-12">
							<div class="form-group"><label>客户投诉</label>
								<textarea name="khtsbt"  class="form-control" check-type="required" readonly="readonly"></textarea>
							</div>
						</div>
					</div>
					<!-- 
					<div class="row">
						<div class="col-md-12">
							<div class="form-group"><label>受理情况</label>
								<textarea name="slqk"  class="form-control" check-type="required" readonly="readonly"></textarea>
							</div>
						</div>
					</div>
					 -->
					<div class="row">
						<div class="col-md-4">
							<div class="form-group"><label class="autoInputLabel">关联交易笔数</label>
								<input type="text" class="form-control" id="tradCount" name="gljybs" value="0" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-4">
							<div class="form-group"><label class="autoInputLabel">关联交易金额</label>
								<input type="text" class="form-control" id="tradJe" name="gljyje" value="0.00" readonly="readonly"/>
							</div>
						</div>
					</div>
					<!-- 公共下部分结束 -->
					
					<!-- 关联交易列表 -->
				   	<div class="box-body">
				   		<input type="hidden" name="joinTradIds" value=""/>
						<table id="iWorkOrderSelGrid_${uuid}_d">
				   		</table>
					</div>
					<!-- 关联交易列表结束 -->
					
				</div>
				<div role="tabpanel" class="tab-pane fade am-margin-top-sm" id="${uuid}_formViewTab">
	       	   </form>
			 </div>
		</div>
		
		<!-- 受理情况部分 -->
		<ul class="nav nav-tabs" role="tablist" id="orderNav">
			<li role="presentation" class="active">
				<a href="#${uuid}_fieldDataTab" role="tab" data-toggle="tab">
					受理情况
				</a>
			</li>
		</ul>
		<div class="tab-content">
			<div class="box-body">
				<table id="iWorkOrderAcceptGrid${uuid}">
		   		</table>
			</div>
		</div>
		<div class="row">
		   <form id="workOrderAccept">
				<div class="col-md-2 dealEl">
					<div class="form-group"><label class="autoInputLabel">工单状态<span id="currentNodeName"></span></label>
						<select class="form-control" name="xyhj" check-type="required">
			                
			            </select>
					</div>
				</div>
				<div class="col-md-7 dealEl">
					<div class="form-group"><label class="autoInputLabel">受理情况</label>
						<input type="hidden" name="gclid" value=""/>
						<textarea name="hjclyj"  class="form-control" check-type="required"></textarea>
						<br/>
					</div>
				</div>
				<div class="col-md-3">
					<div class="form-group"><label id="zhpdtime">&nbsp;</label>
						<div class="checkbox">
				            <button type="button" class="btn btn-warning" id="delayDealBtn">暂缓派单</button>
				            <button type="button" class="btn btn-primary" id="saveDealBtn">保存</button>
				            <button type="button" class="btn btn-primary" id="submitDealBtn">提交</button>
				            <button type="button" class="btn btn-warning" id="reDealBtn">重启工单</button>
				            <button type="button" class="btn btn-primary" id="saveUpdBtn">保存修改</button>
				            <button type="button" class="btn btn-warning" id="reqReturnBtn">请求释放</button>
				            <button type="button" class="btn btn-default" id="reqReturnRecordBtn">
							  	请求记录 <span class="badge">0</span>
							</button>
				            <button type="button" class="btn btn-warning" id="dealReqReturnBtn">
							  	释放 <span class="badge">1</span>
							</button>
				        </div>
					</div>
				</div>
		   </form>
		</div>
		<!-- 受理情况部分结束 -->
		
</div>
<script type="text/javascript">
	
    $(function () {
    	
    	webUtils.nameSpace("wiseMen.workOrder");
		//工单处理状态
    	wiseMen.workOrder.gdclzt='${param.gdclzt}';
    	//当前环节释放请求ID
    	wiseMen.workOrder.sfid='-1';
    	//操作类型
    	wiseMen.workOrder.action='${param.action}';
    	//查看交易详细
    	wiseMen.workOrder.tradingView=function(uuid,rowIndex){
    		var row = $("#iWorkOrderSelGrid_"+uuid+"_d").bootstrapTable("getRowByIndex", rowIndex);
    		var uuid=webUtils.uuid();
    		var d=webUtils.dialog({
    			url:ctx+"/dataModelDefAct/viewTpl.do?dms=DM_TRADING_ORDER&DM_TRADING_ORDER_ID="+row.ID+"&winId="+uuid
    		});
    	}
    	
    	//设置业务类型选择事件
    	wiseMen.workOrder.ywlxSelEvent=function(){
    		var ywlx = $("div[role=tabpanel]").find("select[name=ywlx]");
    		ywlx.unbind("change");
    		ywlx.change(function(){
	    		var tab = $(this).parents("div[role=tabpanel]");
	    		if($(this).val()=='5'){//风控类
	    			tab.find(".serviceWO").hide();
	    			tab.find(".riskWO").show();
	    		}else{//客服类
	    			tab.find(".riskWO").hide();
	    			tab.find(".serviceWO").show();
	    		}
	    		wiseMen.workOrder.setZywlxOption($(this));
	    	});
    		if(ywlx.val()=='5'){//风控类
    			var tabD = ywlx.parents("div[role=tabpanel]");
    			tabD.find(".serviceWO").hide();
    			tabD.find(".riskWO").show();
    		}
    		//隐藏风控类子类型
    		ywlx.parents("div[role=tabpanel]").find("select[name=zywlx]").find('option[value*=5-]').hide();
    	}
    	//设置子业务类型选项
    	wiseMen.workOrder.setZywlxOption=function(ywlx){
    		var tab = ywlx.parents("div[role=tabpanel]");
    		var zywlx = tab.find("select[name=zywlx]");
    		var options = zywlx.find('option');
    		var defaultVal = '';
    		$.each(options,function(index,o){
    			var obj = $(o);
    			if(ywlx.val()=='5'){
	    			if(obj.val().indexOf('5-')!=-1){
	    				if(defaultVal==''){
	    					defaultVal = obj.val();
	    				}
	    				obj.show();
	    			}else{
	    				obj.hide();
	    			}
    			}else{
    				if(obj.val().indexOf('5-')==-1){
    					if(defaultVal==''){
	    					defaultVal = obj.val();
	    				}
	    				obj.show();
	    			}else{
	    				obj.hide();
	    			}
    			}
    		});
    		zywlx.val(defaultVal);
    	}
    	
    	//初始化关联交易列表方法    	
    	wiseMen.workOrder.addIndex = 1;
    	wiseMen.workOrder.renderId = '${uuid}';
    	wiseMen.workOrder.loadTableGrid=function(uuid,index){
	    	var iworkOrderSelGrid = $("#iWorkOrderSelGrid_"+uuid+"_d").bootstrapTable({
	        	url:ctx + "/workOrderAct/queryTarding.do",
	        	columns:[
	    			{title: '关联' , field: 'ID' , width: "50px",formatter:function(data, row, index){
	    					return '<input type="checkbox" id="'+row.ID+'" ddh="'+row.YLDDH+'" je="'+row.JYJE+'" onclick="javascript:wiseMen.workOrder.checkJoin(this);"></input>';
	    				}
	    			},
	    			{title: '开户姓名', field: 'KHXM'},
	    			{title: '交易手机', field: 'JYSJH'},
	    			{title: '银行卡号', field: 'YHZH'},
	    			{title: '银行', field: 'YH'},
	    			{title: '卡种', field: 'KZ'},
	    			{title: '商店名称', field: 'SDMC'},
	    			{title: '商品描述', field: 'SPMS'},
	                {title: '易联订单号', field: 'YLDDH'},
	                {title: '商户订单号', field: 'SHDDH'},
	                {title: '交易金额', field: 'JYJE'},
	                {title: '人民币金额', field: 'RMBJE'},
	                {title: '交易时间', field: 'JYSJ'},
	                {title: '状态', field: 'DDZT'},
	                {title: '支付结果', field: 'ZFJG'},
	                {title: '详细', field: 'ID',formatter:function(data, row, index){
	                	var btn = '<button data-rowindex="0" type="button" title="查看" class="btn btn-default btn-xs am-margin-left-xs am-margin-vertical-xs inGridOptBtn" onclick="javascript:wiseMen.workOrder.tradingView(\''+uuid+'\',\''+index+'\')"><span class="glyphicon glyphicon-search"></span></button>';
	                	return btn;
	                }}
	        	],
	    	    queryParams: function(d) {
	    	        d.ids = $("input[name=joinTradIds").val();
	    	        return d;
	    	    }
	        });
	        $("#"+uuid+"_fieldDataTab"+index).find("#searchSelOrderBt").click(function(){
	        	iworkOrderSelGrid.bootstrapTable("refresh");
	        });
    	}
    	
    	//加载表单初始化数据
        var id = '${param.id}';
        var clid = '${param.clid}';
        var winId = '${param.winId}';
        var action = '${param.action}';
        if (id) {
        	//根据操作类型处理操作按钮的显示与隐藏
        	if(action=='query'){
        		if(wiseMen.workOrder.gdclzt=='2'){
        			$("#workOrderAccept > div").eq(0).eq(1).hide();
        			$("#saveUpdBtn,#reqReturnBtn,#reqReturnRecordBtn,#dealReqReturnBtn").hide();
        		}else{
        			$("#workOrderAccept > div").eq(0).hide();
            		$("textarea[name=hjclyj]").attr("readonly","readonly");
            		$("#delayDealBtn,#saveDealBtn,#submitDealBtn,#reDealBtn,#saveUpdBtn,#dealReqReturnBtn").hide();
            		$("#reqReturnBtn,#reqReturnRecordBtn").show();
        		}
        	}else{
        		$("#reDealBtn,#saveUpdBtn,#reqReturnBtn,#reqReturnRecordBtn,#dealReqReturnBtn").hide();
        	}
            $.getJSON(ctx + '/workOrderAct/queryWorkOrderDealById.do', {id: id,clid:clid}, function (data) {
                //初始化表单数据
            	webUtils.fullForm({
                    form:$("#workOrderByUserForm"),
                    data: data.order
                });
                webUtils.fullForm({
                    form: $("#workOrderForm"),
                    data: data.order
                });
                //初始化已关联交易
                var tradIds = '';
                $.each(data.joinTrad,function(index,obj){
                    if(tradIds!=''){
                    	tradIds+=',';
                    }
                    tradIds+="'"+obj.TID+"'";
                });
                $("input[name=joinTradIds]").val(tradIds);
				//初始化风控/客服可见数据项
            	wiseMen.workOrder.ywlxSelEvent();
            	//初始化第一个工单所关联的交易列表
            	wiseMen.workOrder.loadTableGrid(wiseMen.workOrder.renderId,'');
            	if(data.currnetNode){
	            	//初始化有暂存意见的
	            	if(data.currnetNode.HJCLYJ){
	            		$("textarea[name=hjclyj]").val(data.currnetNode.HJCLYJ);
	            	}
	            	$("#currentNodeName").html("("+data.currnetNode.HJMC+")");
	            	$("input[name=clid]").val(data.currnetNode.ID);
	            	//初始化下一环节信息
	            	var nSelectNodeIds = "";
	            	var nSelectNodes = "";
	            	$.each(data.nextNodes,function(index,node){
	            		if($.trim(node.LZGZ).indexOf('sSelectNode')!=-1){
	                		$("select[name=xyhj]").append("<option value='"+node.ID+"'>"+node.HJMC+"</option>");
	            		}else if($.trim(node.LZGZ).indexOf('nSelectNode')!=-1){
	            			if(nSelectNodeIds!=''){
	            				nSelectNodeIds+=",";
	            				nSelectNodes+="&";
	            			}
	            			nSelectNodeIds+=node.ID;
	            			nSelectNodes+=node.HJMC;
	            		}
	            	});
	            	if(nSelectNodeIds!=''){
	            		$("select[name=xyhj]").append("<option value='"+nSelectNodeIds+"' >"+nSelectNodes+"</option>");
	            	}
	            	//显示暂缓派单信息
	            	if(data.currnetNode.CLZT=='2'){
	            		$("#zhpdtime").html('暂缓派单：'+webUtils.parseTimestamp(new Date(data.currnetNode.ZHPDSJ),"yyyy-MM-dd HH:mm"));
	            	}
            	}
            	//判断是否已办结
            	if(data.order.gdclzt=='2'){
            		$(".dealEl > div").hide();
            		$("#delayDealBtn,#saveDealBtn,#submitDealBtn").hide();
            		$("#reDealBtn").removeClass('hide').show();
            	}
            	//显示释放处理按钮
            	if(data.currnetNode && data.currnetNode.SFZT=='1'){
            		wiseMen.workOrder.sfid = data.currnetNode.SFID;
            		$("#dealReqReturnBtn").show();
            	}
            	//统计释放请求数量
                wiseMen.workOrder.statReqReturn();
            });
        }

    	//修改受理意见
    	wiseMen.workOrder.updAcceptContent=function(clid,rowIndex){
    		$("input[name=gclid]").val(clid);
    		var content = wiseMen.workOrder.acceptTableGrid.getGrid().bootstrapTable("getRowByIndex", rowIndex).HJCLYJ;
    		$("textarea[name=hjclyj]").val(content).removeAttr("readonly");
    		$("#saveUpdBtn").show();
    	}
    	//受理情况列表
    	wiseMen.workOrder.acceptTableGrid = null;
    	wiseMen.workOrder.loadAcceptTableGrid=function(uuid){
    		requirejs(['wiseMen/dataModel/QueryDefTpl'],function(QueryDefTpl){
    			wiseMen.workOrder.acceptTableGrid=new QueryDefTpl({
	    			code:"DM_WORKORDER_DEAL",
	    			searchBarType:"dialog",
	    			selectModel:"single",
	    			gridDiv:"#iWorkOrderAcceptGrid"+uuid,
	    			queryDatas:{YWGDID:id,CLZT:'-1'}
	    		});
    		});
    	}
    	wiseMen.workOrder.loadAcceptTableGrid(wiseMen.workOrder.renderId);
    	
        $("#workOrderAccept").validation();
        //提交数据
        wiseMen.workOrder.submitData=function(action){
        	var hjclyj = $("textarea[name=hjclyj]");
        	if($.trim(hjclyj.val())!=''){
        		if(action=='2'){
        			var windSt=webUtils.dialog({
        	          	 title:'设置延缓派单时间',
        	          	 url:ctx + "/workOrderAct/workOrderSelTime.do?winId=selectHdsj",
        	          	 width:400,
        	          	 height:450
        	           });
        	        webUtils.topicSubscribe("dialog.submit.success.selectHdsj",function(data){
        				$("input[name=zhpdsj]").val(data.selTime);
        				windSt.close();
        				wiseMen.workOrder.AjaxData();
        			},true);
        		}else{
        			wiseMen.workOrder.AjaxData();
        		}
        	}else{
        		layer.msg("请填写受理情况！");
        		hjclyj.focus();
        	}
        }
        
        //Ajax提交
        wiseMen.workOrder.AjaxData=function(){
        	var orderDataForms=$("#workOrderForm");
			var orderDataFormObj = webUtils.formToObj(orderDataForms);
			orderDataFormObj.xyhj=$("select[name=xyhj]").val();
			orderDataFormObj.hjclyj=$("textarea[name=hjclyj]").val();
    		$.post(ctx + '/workOrderAct/dealWorkOrder.do',{orderDatas:Base64.encode(JSON.stringify(orderDataFormObj))},function (data) {
                    if (data.success) {
                    	layer.msg("处理工单操作成功！");
                        top.webUtils.topicPublish("dialog.submit.success."+winId, data);
                    } else {
                    	webUtils.error(data.msg);
                    }
                }
            );
        }
        
        //暂存处理信息        
        $("#saveDealBtn").click(function () {
        	$("input[name=clzt]").val('0');
        	wiseMen.workOrder.submitData('0');
        });
        //处理信息        
        $("#submitDealBtn").click(function () {
        	$("input[name=clzt]").val('1');
        	wiseMen.workOrder.submitData('1');
        });
        //暂缓处理信息
        $("#delayDealBtn").click(function () {
        	$("input[name=clzt]").val('2');
        	wiseMen.workOrder.submitData('2');
        });
        //重启工单
        $("#reDealBtn").click(function(){
        	var windSet=webUtils.dialog({
	          	 title:'重启工单',
	          	 url:ctx + "/workOrderAct/setReStartDeal.do?winId=setReDeal",
	          	 width:400,
	          	 height:260
	        });
	        webUtils.topicSubscribe("dialog.submit.success.setReDeal",function(data){
	        	$.post(ctx + '/workOrderAct/reStartDeal.do',{id:$("input[name=id]").val(),cqbj:"1",cqyy:data.cqyy},function (ndata) {
	                    if (ndata.success) {
	                    	layer.msg("重启工单操作成功！");
	                        webUtils.topicPublish("dialog.submit.success."+winId, ndata);
	                    } else {
	                    	webUtils.error(data.msg);
	                    }
               		}
            	);
				windSet.close();
			},true);
        });
        //修改环节受理情况
        $("#saveUpdBtn").click(function(){
        	if($("input[name=gclid]").val()!='' && $.trim($("textarea[name=hjclyj]").val())!=''){
        		$.post(ctx + '/workOrderAct/updDealData.do',{gclid:$("input[name=gclid]").val(),hjclyj:$("textarea[name=hjclyj]").val()},function (ndata) {
                    if (ndata.success) {
                        layer.msg('修改受理请求信息成功！');
                        wiseMen.workOrder.acceptTableGrid.getGrid().bootstrapTable("refresh");
                    } else {
                    	layer.msg(data.msg);
                    }
           		   }
        		);
        	}
        });
      	//修改环节受理情况
        $("#reqReturnBtn").click(function(){
        	var windSet=webUtils.dialog({
	          	 title:'释放操作',
	          	 url:ctx + "/workOrderAct/reqReturnView.do?winId=reqRetuanAction",
	          	 width:500,
	          	 height:350
	        });
	        webUtils.topicSubscribe("dialog.submit.success.reqRetuanAction",function(data){
	        	$.post(ctx + '/workOrderAct/reqReturnDeal.do',{gdid:$("input[name=id]").val(),sfyy:data.sfyy,qtsm:data.qtsm},function (ndata) {
	                    if (ndata.success) {
	                        wiseMen.workOrder.statReqReturn();
	                        layer.msg('提交请求释放操作成功！');
	                    } else {
	                    	layer.msg('请求释放失败！');
	                    }
              		}
           		);
				windSet.close();
			},true);
        });
        //修改环节受理情况
        $("#dealReqReturnBtn").click(function(){
        	var windSet=webUtils.dialog({
	          	 title:'释放操作',
	          	 url:ctx + "/workOrderAct/returnDealView.do?winId=retuanAction&sfid="+wiseMen.workOrder.sfid,
	          	 width:500,
	          	 height:400
	        });
	        webUtils.topicSubscribe("dialog.submit.success.retuanAction",function(data){
	        	$.post(ctx + '/workOrderAct/returnDeal.do',{sfhjid:$("input[name=clid]").val(),id:wiseMen.workOrder.sfid},function (ndata) {
	                    if (ndata.success) {
	                    	top.webUtils.topicPublish("dialog.submit.success."+winId, data);
	                        layer.msg('释放成功，工单退回至['+data.returnNodeName+']！');
	                    } else {
	                    	layer.msg('操作释放失败！');
	                    }
              		}
           		);
				windSet.close();
			},true);
        });
        //查询请求释放记录
        $("#reqReturnRecordBtn").click(function(){
        	var windRecord=webUtils.dialog({
	          	 title:'请求释放记录',
	          	 url:ctx + "/workOrderAct/reqReturnRecordView.do?gdid="+$("input[name=id]").val(),
	          	 width:850,
	          	 height:500
	        });
        });
        //统计请求释放记录
        wiseMen.workOrder.statReqReturn=function(){
        	$.post(ctx + '/workOrderAct/queryReqReturnRecordCount.do',{gdid:$("input[name=id]").val()},function (ndata) {
                $("#reqReturnRecordBtn > span").html(ndata.counts);
      		   }
   			);
        }
    });    
</script>
